<template>
    <div class="att-header">
        <div class="att-wrapper">
            <div><span>{{username}}</span></div>
            <div>
                <Button type="primary" size="small" @click="changPwd">修改密码</Button>
            </div>
            <div>
                <Button type="error" size="small" @click="logout">退出</Button>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "AttHeader",
        data() {
            return {
                username: localStorage.getItem("username")
            }
        },
        methods: {
            logout() {
                localStorage.clear();
                this.$router.push("/login");
            },

            //修改密码
            changPwd() {
                this.$router.push("/change/pwd")
            }
        }
    }
</script>

<style scoped>
    .att-header {
        width: 100%;
        height: 50px;
        background-color: white;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        text-align: right;
    }

    .att-wrapper {
        font-size: 16px;
        margin-right: 20px;
        display: flex;
    }

    .att-wrapper > div:not(:last-child) {
        margin-right: 20px;
    }

    .att-wrapper > span {
        margin-right: 7px;
    }
</style>
